package com.yang.app.servlet;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.yang.app.entity.User;

/**
 * Servlet implementation class JfreeChartServlet
 */
/*@WebServlet("/jfreeChart.do")*/
public class JfreeChartServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public JfreeChartServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	public void init(ServletConfig config) throws ServletException {
		// TODO Auto-generated method stub
		System.out.println("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		List<User> list = new ArrayList<User>();
		List<User> list2 = new ArrayList<User>();
		Map<String , Object> map = new HashMap<String ,Object>();
		User user = new User();
		user.setPassword("123456");
		user.setUserName("yangcs");
		
		User user1 = new User();
		user1.setPassword("654321");
		user1.setUserName("sheng");
		list.add(user);
		list.add(user1);
		
		String json = JSON.toJSONString(list);
		response.setContentType("application/json; charset=utf-8");
		OutputStream out = null;
		out = response.getOutputStream();
		//out.write(json.getBytes(response.getCharacterEncoding()));
		out.write(json.getBytes());
		out.flush();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
